package com.fowo.api.sys.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.R;
import com.fowo.api.sys.entity.SysImportTemplate;
import com.fowo.api.sys.service.SysImportTemplateService;
import com.fowo.api.sys.model.SysImportTemplateSearchParamPo;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 系统导入模版控制器
 * @author yl_ls
 */
@RestController
@RequestMapping("api/sys/import-template")
public class SysImportTemplateController {
    @Resource
    private SysImportTemplateService service;

    @Operation(summary = "分页查询")
    @GetMapping("page")
    public R<Page<?>> page(SysImportTemplateSearchParamPo search) {
        return R.data(() -> service.searchPage(search));
    }

    @Operation(summary = "新建")
    @PostMapping
    public R<Long> create(@RequestBody SysImportTemplate sysImportTemplate) {
        return R.data(() -> service.create(sysImportTemplate));
    }

    @Operation(summary = "更新")
    @PutMapping
    public R<?> update(@RequestBody SysImportTemplate sysImportTemplate) {
        return R.run(() -> service.update(sysImportTemplate));
    }

    @Operation(summary = "删除")
    @DeleteMapping("{id}")
    public R<?> delete(@PathVariable Long id) {
        return R.run(() -> service.delete(id));
    }
}
